package java.hilyb.dbtest.provider;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.net.Uri;

import java.hilyb.dbtest.DBHelper;

/**
 * User: wlai
 * Date: 12/11/2014
 * Time: 14:35 PM
 */
public class CategoryProvider extends ContentProvider {
    public static final Uri CONTENT_URI = Uri.parse("content://java.hilyb.dbtest/");

    private static final UriMatcher sUriMatcher;

    static {
        sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
        // 这个地方的persons要和PersonColumns.CONTENT_URI中最后面的一个Segment一致
        sUriMatcher.addURI("java.hilyb.dbtest", "categories", 1);
        sUriMatcher.addURI("java.hilyb.dbtest", "categories/#", 2);

    }

    private DBHelper dbHelper;


    @Override
    public boolean onCreate() {
        dbHelper = new DBHelper(getContext());
        return false;
    }

    @Override
    public Cursor query(Uri uri, String[] strings, String s, String[] strings2, String s2) {
        switch (sUriMatcher.match(uri)) {
            case 1:
            case 2:
                break;
            default:
                throw new IllegalArgumentException("Unknown URI " + uri);
        }
        return null;
    }

    @Override
    public String getType(Uri uri) {
        switch (sUriMatcher.match(uri)) {
            case 1:
                return "All";
            case 2:
                return "ByID";
            default:
                throw new IllegalArgumentException("Unknown URI " + uri);
        }
    }

    @Override
    public Uri insert(Uri uri, ContentValues contentValues) {
        switch (sUriMatcher.match(uri)) {
            case 1:
                break;


        }
        return null;
    }

    @Override
    public int delete(Uri uri, String s, String[] strings) {
        return 0;
    }

    @Override
    public int update(Uri uri, ContentValues contentValues, String s, String[] strings) {
        return 0;
    }
}
